package cn.wolfcode.luowowo.website.controller;

import cn.wolfcode.luowowo.article.domain.*;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.article.service.IHotelService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("hotel")
public class HotelController {

    @Reference
    private IDestinationService destinationService;

    @Reference
    private IHotelService hotelService;

    @RequestMapping("")
    public String index(Model model){
        List<Destination> dests = destinationService.getDestByRegionId(-1L);
        List<Destination> overseas = destinationService.getAbroadByRegion();
        List<Hotel> hotels = hotelService.selectAllHotel();
        List<HotelCity> hotelCities = hotelService.selectAllCities();
        model.addAttribute("dest", dests);
        model.addAttribute("overseas", overseas);
        model.addAttribute("hotelTags",hotels);
        model.addAttribute("hotelCity", hotelCities);
        return "hotel/hotel";
    }

    @RequestMapping("/theme")
    public String theme(Model model, String content){
        List<HotelCommend> hotelCommends = hotelService.selectAllHotelCommend(content);
        model.addAttribute("list", hotelCommends);
        return "hotel/hotelTpl";
    }

    @RequestMapping("/theme1")
    public String theme1(Model model, String name){
        List<HotelScore> hotelScores = hotelService.selectAllHotelScore(name);
        model.addAttribute("hotelScore", hotelScores);
        return "hotel/hotelTpl1";
    }
}
